From 78bc404b6b298e69910b4eefcad0aa50595d6023 Mon Sep 17 00:00:00 2001 From: Ewan Mellor Date: Mon, 4 Dec 2006 10:20:56 +0000 Subject: [PATCH] With PERMISSIVE turned on, diagnose missing Enums and Bools, and improve the diagnosis of missing structure values. Signed-off-by: Ewan Mellor --- tools/libxen/src/xen_common.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/tools/libxen/src/xen_common.c b/tools/libxen/src/xen_common.c index 50b8e377e0..ea0909d1a4 100644 --- a/tools/libxen/src/xen_common.c +++ b/tools/libxen/src/xen_common.c @@ -518,8 +518,14 @@ static void parse_into(xen_session *s, xmlNode *value_node, xmlChar *string = string_from_value(value_node, "string"); if (string == NULL) { +#if PERMISSIVE + fprintf(stderr, + "Expected an Enum from the server, but didn't get one\n"); + ((int *)value)[slot] = 0; +#else server_error( s, "Expected an Enum from the server, but didn't get one"); +#endif } else { @@ -567,8 +573,14 @@ static void parse_into(xen_session *s, xmlNode *value_node, xmlChar *string = string_from_value(value_node, "boolean"); if (string == NULL) { +#if PERMISSIVE + fprintf(stderr, + "Expected a Bool from the server, but didn't get one\n"); + ((bool *)value)[slot] = false; +#else server_error( s, "Expected a Bool from the server, but didn't get one"); +#endif } else { @@ -764,7 +776,6 @@ static void parse_into(xen_session *s, xmlNode *value_node, cur = cur->next; } -#if !PERMISSIVE /* Check that we've filled all fields. */ for (size_t i = 0; i < member_count; i++) { @@ -781,15 +792,20 @@ static void parse_into(xen_session *s, xmlNode *value_node, if (j == seen_count) { +#if PERMISSIVE + fprintf(stderr, + "Struct did not contain expected field %s.\n", + mem->key); +#else server_error_2(s, "Struct did not contain expected field", mem->key); free(result); free(checklist); return; +#endif } } -#endif free(checklist); ((void **)value)[slot] = result; -- 2.30.2